package com.csq.portal.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.csq.cms.service.RedisService;
import com.csq.manager.pojo.Enterprise;

@Controller
@RequestMapping("/portal/company")
public class CompanyController {

	@Autowired
	private RedisService redisService;

	@RequestMapping(value = "/index")
	public String index(String username, HttpServletRequest request) {

		// 从 redis 获取 session

		Enterprise redisEnterprise = redisService.getRedisEnterprise(username);

		if (redisEnterprise == null) {
			return "redirect:http://localhost:8080/sso-web/web/company/login";
		}

		request.getSession().setAttribute("enterprise", redisEnterprise);
		return "/web/company/index";
	}

	@RequestMapping(value = "/editCompany")
	public String editCompany() {

		return "/web/company/editCompany";
	}
	
	@RequestMapping(value = "/verifyCompany")
	public String verifyCompany() {

		return "/web/company/verifyCompany";
	}
	
	@RequestMapping(value = "/editPassword")
	public String editPassword() {

		return "/web/company/editPassword";
	}
}
